<?php
namespace App\Models\System;


use App\Models\Model;
use Illuminate\Support\Facades\DB;


class DefaultGroup extends Model
{
    protected $table = 'default_groups'; 

    protected $appends = [
       
    ];

    public function user()
    {
        return $this->hasOne(User::class,'user_id','author');
    }

    /**
     * 递归获取数据
     * @author lxy
     * @datetime 2022-11-18
     */
    public function childrenMembres()
    {
        return $this->hasMany(self::class,'pid','id')
            ->select('id','pid','is_node')
            ->where('status','!=',0)
            ->with('childrenMembres');
    }

     /**
     * 递归获取数据
     * @author lxy
     * @datetime 2022-11-18
     */
    public function children()
    {
        return $this->hasMany(self::class,'pid','id')
            ->select('id','title','pid','value')
            ->with(['children']);
    }
   
     

}